﻿if object_id('dbo.SchemaChanges') is not null drop table dbo.SchemaChanges

create table dbo.SchemaChanges
(
	id int identity primary key,
	createdDate datetime default getdate(),
	name nvarchar(1024)
)
go

create function dbo.scriptExisted(@name nvarchar(1024))
returns bit
as
begin
	declare @result bit

	if exists(select top 1 id from dbo.SchemaChanges where name = @name)
		set @result = 1
	else
		set @result = 0
	return @result
end
go

create proc dbo.updateScript @name nvarchar(1024)
as
begin
	if dbo.scriptExisted(@name) = 0 insert into dbo.SchemaChanges(name) values(@name)
end
go